<script type="text/javascript" src="@{'/public/javascripts/rotate.js'}"></script>
<div class="xf_ht_jr_obu_width">
  <div class="xf_ht_ptjkb_shok">
    <ul class="xf_ht_ptjkb_shok_ul">
      <li>用户名：${item?.userName}</li>
      <li>科目种类：${item?.auditItem?.name}</li>
      <li>
        <div class="xf_ht_ptjkb_lilist_l"> 素材(如果加载失败，请下载后查看!)：</div>
        <div class="xf_ht_ptjkb_lilist_r">
          <input type="button" value="上一个" onclick="showLastItem();" id="lastItem">
          <input type="button" value="下一个" onclick="showNextItem();" id="nextItem" >
        </div>
        <div class="clear"></div>
        <div class="xf_ht_ptjkb_lilist_img" id="showImag"></div>
        <div id="notIsImag" style="display: none;">
		      科目资料：<a href="@{Application.downloadFiles(item?.strItems, item?.auditItem?.type)}">下载</a>
		</div>
        <div class="xf_ht_ptjkb_lilist_button" id="isImag" style="display: none;">
          <input type="button" value="放大" onclick="imgToSize(20)"/>
	      <input type="button" value="缩小" onclick="imgToSize(-20)"/>
		  <input type="button" value="右翻转" onclick="$('#imageFileName').rotateRight();"/>
		  <input type="button" value="左翻转" onclick="$('#imageFileName').rotateLeft();"/>
		  <input type="button" value="还原" onclick="restore();" />
         </div>
      </li>
    </ul>
  </div>
  <div class="xf_ht_ptjbk_shok_bottom">
    <table border="0" cellspacing="15" cellpadding="0" class="xf_ht_jr_obu_form xf_ht_sh_form2" width="100%">
      <tr>
        <td align="center" width="88">科目可见性：</td>
        <td>
	      #{if item?.isVisible}
		         可见
		  #{/if}
		  #{else}
		        不可见
		  #{/else}
        </td>
      </tr>
      <tr>
        <td align="right" width="88">审核状态：</td>
        <td>
          ${item?.strStatus}
        </td>
      </tr>
      <tr>
        <td align="right" valign="top" class="xf_ht_jr_obttd_l">审核意见：</td>
        <td>
          <textarea class="xf_ht_jr_obttd_textarea xf_ht_jr_obttd_textarea2" style="max-width:400px;" disabled="disabled">${item?.suggestion}</textarea>
        </td>
      </tr>
    </table>
  </div>
</div>
<script type="text/javascript">
<!--
	var nowItem = 0;
	var itemLen = 0;
	var items = null;
		
	$(function(){
		restore();
	});

	/* 上一个资料 */
	function showLastItem(){
		nowItem--;
		showImag((nowItem == 0? subItem(0) : items[nowItem]));
		
		$("#nextItem").removeAttr("disabled");
		
		if(nowItem <= 0){
			$("#lastItem").attr("disabled","disabled");
			nowItem = 0;
			return;
		}

		$("#lastItem").removeAttr("disabled");
	}

	/* 下一个资料 */
	function showNextItem(){
		nowItem++;
		showImag((nowItem == (itemLen-1)? subItem(nowItem) : items[nowItem]));

		$("#lastItem").removeAttr("disabled");
		
		if(nowItem >= itemLen-1){
			$("#nextItem").attr("disabled","disabled");
			nowItem = itemLen-1;
			return;
		}
		
		$("#nextItem").removeAttr("disabled");
	}

	/* 截取多余的'[' 或者 ']' */
	function subItem(index){
		var img = items[index];
		var len = img.length;

		if(itemLen == 1){
			img = img.substring(1, len);
			return img.substring(0, img.length-1)
		}
		
		if(index == 0)
			img = img.substring(1, len);
		else
			img = img.substring(0, len-1);
		
		return img;
	}
	
	/* 还原 */
	function restore(){
		nowItem = 0;
		try{
			items = '${item?.items}'.trim().split(","); // 把Java集合转为js数组
		}catch(e){
			return;
		}
		
		if(null == items){
			alert("图片加载有误!");
			
			return;
		}
		
		itemLen = items.length;
		
		$("#lastItem").attr("disabled","disabled");
		if(itemLen <= 1){
			$("#nextItem").attr("disabled","disabled");
		}else{
			$("#nextItem").removeAttr("disabled");
		}
		
		showImag(subItem(nowItem));
	}

	function showImag(src){
		var isImag = $("#isImag");
		var showImag = $("#showImag");
		var notIsImag = $("#notIsImag");
		
		var len = src.lastIndexOf(".");
		var ext = src.substr((len + 1), 3);

		if( ext != 'gif' && 
			ext != 'jpg' && 
			ext != 'jpeg' && 
			ext != 'png' &&
			ext != 'bmp' 
		){
			 isImag.hide();
			 showImag.hide();
			 notIsImag.show();
			 
			 return;
		}else{
			var html = '<img src="'+src+'" id="imageFileName" title="${item?.auditItem?.name}" width="250" height="250">';
			isImag.show();
			showImag.html(html).show();
		    notIsImag.hide();
		}
	}

	/* 放大缩小图片 */
	function imgToSize(size) {
		var img = $("#imageFileName");
		var oWidth=img.width(); //取得图片的实际宽度
		var oHeight=img.height(); //取得图片的实际高度
		var w = 0;
		var h = 0;
		if(oWidth > 380 || oHeight > 380){
			w = 380;
			h = 380;
		}else{
			w = oWidth + size;
			if(w > 380 || w < 180) return;
			h = oHeight + size/oWidth * oHeight;
		}
		img.width(w);
		img.height(h);
	}

//-->
</script>